package com.example.demo.design.demo18_memento;

/**
 * Created by 蔡超 on 2018/10/4.
 */
public class GamRole {
    private Integer vit;
    private Integer atk;
    private Integer def;

    public GamRole(Integer vit, Integer atk, Integer def) {
        this.vit = vit;
        this.atk = atk;
        this.def = def;
    }

    public RoleStateMemento saveState(){
        RoleStateMemento RoleStateMemento = new RoleStateMemento(vit,atk,def);
        return RoleStateMemento;
    }

    public void recoveryState(RoleStateMemento roleStateMemento){
        vit = roleStateMemento.getVit();
        atk = roleStateMemento.getAtk();
        def = roleStateMemento.getDef();
    }

    public void fight(){
        vit = 0;
        atk = 0;
        def = 0;
    }

    @Override
    public String toString() {
        return "GamRole{" +
                "vit=" + vit +
                ", atk=" + atk +
                ", def=" + def +
                '}';
    }
}
